﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Project_02
{
    public partial class Connection : Form
    {
        private Database database;
        public Connection()
        {
            InitializeComponent();
            database = null;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Int32 timeout = 5;
            try {
                timeout = Convert.ToInt32(timeoutUpDown.Text);
            } catch(FormatException ex) {
                timeout = 5;
            }
            try {
                database = new Database(serverTextBox.Text, usernameTextBox.Text, passwordTextBox.Text, timeout);
                Close();
            } catch(Exception ex) {
                MessageBox.Show(ex.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        public Database GetDatabase() {
            return database;
        }
    }
}
